package com.keepmoving.web;

import com.keepmoving.po.Coach;
import com.keepmoving.po.Physical;
import com.keepmoving.service.CoachPhysicalService;
import com.keepmoving.service.CoachService;
import com.keepmoving.service.PhysicalService;
import com.keepmoving.vo.CoachPhysical;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 南丁格尔图
 * @author gyy
 */
@Controller
public class CoachPhysicalController {
    @Resource
    PhysicalService physicalService;

    @Resource
    CoachService coachService;

    @RequestMapping("/topiephysical")
    public String topiephysical(Model model){
        System.out.println("-------");
        List<Coach> list=coachService.showAll();
//        Coach coach=coachService.showByCoId(1001);
        model.addAttribute("physicallist",list);
        return "pieinfo";
    }
    @RequestMapping("/piephysical")
    public @ResponseBody Integer[] piephysical(HttpSession session){
        Integer coIds=(Integer) session.getAttribute("coId");
        int coId=coIds;
        System.out.println(coId);
        Coach coach=coachService.showByCoId(coId);
        System.out.println(coach.getpId());
        List<Integer> list = physicalService.findCulms(coach.getpId());
        Integer[] array=list.toArray(new Integer[5]);
        System.out.println(Arrays.toString(array));
        return array;
    }

    @RequestMapping("/piephysicalall")
    public @ResponseBody Integer[] piephysicalall(int coId){
        System.out.println(coId);
        Coach coach=coachService.showByCoId(coId);
        System.out.println(coach.getpId());
        List<Integer> list = physicalService.findCulms(coach.getpId());
        Integer[] array=list.toArray(new Integer[5]);
        System.out.println(array.toString());
        return array;
    }

}
